<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script type="text/javascript">
	var resourceTree;
	$(function() {
		$('#organizationId').combotree({
			url : '${ctx}/auth/organization_tree',
			parentField : 'pid',
			lines : true,
			panelHeight : 'auto',
			value : '${user.organization.id}'
		});

		resourceTree = $('#roleIds').combotree(
				{
					url : '${ctx}/auth/role_tree',
					parentField : 'pid',
					lines : true,
					panelHeight : 'auto',
					multiple : true,
					required : true,
					cascadeCheck : false,
					value : $.stringToList("${roleIds}"),
					onLoadSuccess : function(node, data) {
						var ids = "${roleIds}";
						if (ids.length > 0) {
							for ( var i = 0; i < ids.length; i++) {
								if (resourceTree.tree('find', ids[i])) {
									resourceTree.tree('check', resourceTree
											.tree('find', ids[i]).target);
								}
							}
						}
					}
				});

		$('#userEditForm').form({
			url : '${ctx}/auth/user_edit',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				progressClose();
				result = $.parseJSON(result);
				if (result.success) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('错误', result.msg, 'error');
				}
			}
		});
		$("#sex").val('${user.sex}');
		$("#usertype").val('${user.usertype}');
		$("#state").val('${user.state}');
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title=""
		style="overflow: hidden; padding: 3px;">
		<form id="userEditForm" method="post">
			<div class="light-info" style="overflow: hidden; padding: 3px;">
				<div>密码不修改请留空。</div>
			</div>
			<table class="grid">
				<tr>
					<input name="user.createdatetime" type="hidden"
						value="${user.createdatetime}">
						<input name="user.isdefault" type="hidden"
						value="${user.isdefault}">
						
					<td>登录名</td>
					<td><input name="user.id" type="hidden" value="${user.id}">

						<input name="user.loginname" type="text" placeholder="请输入登录名称"
						class="easyui-validatebox" data-options="required:true"
						value="${user.loginname}"></td>
					<td>姓名</td>
					<td><input name="user.name" type="text" placeholder="请输入姓名"
						class="easyui-validatebox" data-options="required:true"
						value="${user.name}"></td>
				</tr>
				<tr>
					<td>密码</td>
					<td><input type="password" name="user.password"
						value="${user.password}" /></td>
					<td>性别</td>
					<td><select name="user.sex" id="sex" class="easyui-combobox"
						data-options="width:140,height:29,editable:false,panelHeight:'auto'">
							<option value="0">男</option>
							<option value="1">女</option>
					</select></td>
				</tr>
				<tr>
					<td>年龄</td>
					<td><input type="text" name="user.age" value="${user.age}"
						class="easyui-numberbox" /></td>
					<td>用户类型</td>
					<td><select id="usertype" name="user.usertype"
						class="easyui-combobox"
						data-options="width:140,height:29,editable:false,panelHeight:'auto'">
							<option value="0">管理员</option>
							<option value="1">用户</option>
					</select></td>
				</tr>
				<tr>
					<td>部门</td>
					<td><select id="organizationId" name="user.organization.id"
						style="width: 140px; height: 29px;" class="easyui-validatebox"
						data-options="required:true"></select></td>
					<td>角色</td>
					<td><input id="roleIds" name="roleIds"
						style="width: 140px; height: 29px;" /></td>
				</tr>
				<tr>
					<td>电话</td>
					<td><input type="text" name="user.phone"
						class="easyui-numberbox" value="${user.phone}" /></td>
					<td>用户状态</td>
					<td><select id="state" name="user.state"
						class="easyui-combobox"
						data-options="width:140,height:29,editable:false,panelHeight:'auto'">
							<option value="0">正常</option>
							<option value="1">停用</option>
					</select></td>
					
				</tr>
		<!-- 		<td><select id="isdefault" name="user.isdefault"
						class="easyui-combobox"
						data-options="width:140,height:29,editable:false,panelHeight:'auto'">
							<option value="0">默认</option>
							<option value="1">否</option>
					</select></td> -->
			</table>
		</form>
	</div>
</div>